﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;

namespace DAO
{
    public class LoaiHangDao
    {
        public IEnumerable<LOAIHANG> LoaiHang()
        {
            DoixeDataContext TV = new DoixeDataContext();
            return TV.LOAIHANGs;
        }
        public int LayMaLoaiHang(string TenLoaiHang)
        {
            DoixeDataContext TV = new DoixeDataContext();
            IEnumerable<LOAIHANG> lhDto;
            lhDto = from lh in TV.LOAIHANGs where lh.TenLoaiHang == TenLoaiHang select lh;
            if (lhDto.Count() == 0)
            {
                return -1;
            }
            return lhDto.Single().MaLoaiHang;
        }
    }
}
